﻿using Microsoft.AspNetCore.Mvc;
using NetCore.Common.Helper;
using NetCore.Model.VeiwModels;
using System.Threading.Tasks;

namespace NetCore.WebApi.Controllers
{
    public class EmailController : BaseController
    {
        //private readonly IMain_RedisCacheManager _redisCacheManager;
        private readonly IEmailsHelper _emailsHelper;

        public EmailController(IEmailsHelper emailsHelper)//IMain_RedisCacheManager redisCacheManager,
        {
            //_redisCacheManager = redisCacheManager;
            _emailsHelper = emailsHelper;
        }

        /// <summary>
        /// 测试Redis
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> SendMail(Mail mail)
        {
            if (await _emailsHelper.SendEmails(mail))
                return Ok(JsonReturnHelper.Success("邮件发送成功"));
            else
                return Ok(JsonReturnHelper.Fail("发送邮件时发送了异常"));
        }
    }
}